#include <bits/stdc++.h>

using namespace std;

class TextEditor
{
    string left, right;

    string text()
    {
        return left.substr(max((int)left.size() - 10, 0));
    }

public:
    void addText(string text)
    {
        left += text;
    }

    int deleteText(int k)
    {
        k = min(k, (int)left.length());
        left.resize(left.length() - k);
        return k;
    }

    string cursorLeft(int k)
    {
        while (k && !left.empty())
        {
            right += left.back();
            left.pop_back();
            k--;
        }
        return text();
    }

    string cursorRight(int k)
    {
        while (k && !right.empty())
        {
            left += right.back();
            right.pop_back();
            k--;
        }
        return text();
    }
};
